﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NewCapturerDemo
{
    /// <summary>
    /// The enumeration specifies a setting on a camera.
    /// </summary>
    public enum CamProc : int
    {
        Brightness = 0,  // 亮度
        Contrast = 1,     // 对比度
        Hue = 2,            // 色调
        Saturation = 3, //饱和度
        Sharpness = 4,  // 锐度
        Gamma = 5,      // 伽马
        WhiteBalance = 6,   // 白平衡
        Backlight = 7,          // 逆光对比
        Gain = 8,                   // 增益
        Exposure = 9,           // 曝光
        Focus = 10,               // 焦点
    }

    public class PropPair
    {
        public PropPair()
        {
           
        }

        public PropPair(string name)
        {
            _name = name;
        }

        private int _min = 0;
        public int Min
        {
            get { return _min; }
            set { _min = value; }
        }

        private int _max = 0;
        public int Max
        {
            get { return _max; }
            set { _max = value; }
        }

        private int _value = 0;
        public int Value
        {
            get { return _value; }
            set { _value = value; }
        }

        private string _name = "";
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        private bool _auto = false;
        public bool Auto
        {
            get { return _auto; }
            set { _auto = value; }
        }

        public void LoadSetting()
        {
            int.TryParse(IniCom.IniValue(_name, "min"), out _min);
            int.TryParse(IniCom.IniValue(_name, "max"), out _max);
            _value = int.Parse(IniCom.IniValue(_name, "value"));
            _auto = Convert.ToBoolean(IniCom.IniValue(_name, "auto"));
        }

        public void SaveSetting()
        {
            IniCom.WriteValue(_name, "min", _min.ToString());
            IniCom.WriteValue(_name, "max", _max.ToString());
            IniCom.WriteValue(_name, "value", _value.ToString());
            IniCom.WriteValue(_name, "auto", _auto.ToString());
        }

        public void SaveCurrentValue()
        {        
            IniCom.WriteValue(_name, "value", _value.ToString());
            IniCom.WriteValue(_name, "auto", _auto.ToString());
        }
    }
}
